export interface Document {
  id: number;
  title: string;
  description: string;
  text: string;
  createTime: Date;
  updateTime: Date;
}

export function add(entity: Document): Promise<R<Document>> {
  return useAPI("/content/document", {
    method: "POST",
    body: entity,
  });
}

export function getById(id: number): Promise<R<Document>> {
  return useAPI(`/content/document/${id}`, {
    method: "GET",
  });
}

export function updateById(entity: Document): Promise<R<Document>> {
  return useAPI(`/content/document`, {
    method: "PUT",
    body: entity,
  });
}

export function deleteById(id: number): Promise<R<number>> {
  return useAPI(`/content/document/${id}`, {
    method: "DELETE",
  });
}

export function deleteByIds(ids: number[]): Promise<R<number>> {
  return useAPI(`/content/document`, {
    method: "DELETE",
    body: ids,
  });
}

export function list(entity: Document): Promise<R<Document[]>> {
  return useAPI(`/content/document/list`, {
    method: "POST",
    body: entity,
  });
}

export function page(
  entity: Document,
  page: number,
  size: number
): Promise<R<Document[]>> {
  return useAPI(`/content/document/page/${page}/${size}`, {
    method: "POST",
    body: entity,
  });
}

export function count(entity: Document): Promise<R<number>> {
  return useAPI(`/content/document`, {
    method: "POST",
    body: entity,
  });
}
